{% extends 'layout.html' %}
{% load static %}
{% load permission %}
{% block content %}
    <div style="margin-bottom: 5px;">
        <a class="btn btn-success" href="{% url 'vendor_add' %}"><span class="glyphicon glyphicon-plus-sign"></span>
            新建
        </a>
        <div class="right">
            <form class="form-inline" method="get">
                <div class="form-group">
                    <input name="keyword" type="text" class="form-control" placeholder="请输入关键字" value="{{ keyword }}">
                </div>
                <button type="submit" class="btn btn-primary">
                    <span class="glyphicon glyphicon-search"></span>
                </button>
            </form>

        </div>
    </div>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>厂商</th>
            {% if request|has_permission:"vendor_edit,vendor_delete" %}
                <th>操作</th>
            {% endif %}
        </tr>
        </thead>
        <tbody>
        {% for row in pager.queryset %}
            <tr row-id="{{ row.id }}">
                <td>{{ row.title }}</td>
                {% if request|has_permission:"vendor_edit,vendor_delete" %}
                    <td>
                        {% edit_permission request 'vendor_edit' pk=row.id %}
                        {% delete_permission request 'vendor_delete' pk=row.id %}
                    </td>
                {% endif %}
            </tr>
        {% endfor %}
        </tbody>
    </table>

    <ul class="pagination">
        {{ pager.html }}
    </ul>

    {% include 'include/delete_modal.html' %}
{% endblock %}

{% block js %}
    <script src="{% static 'js/delete_modal.js' %}"></script>
    <script>
        var DELETE_ID;
        var DELETE_URL = "{% url 'vendor_delete' %}";
    </script>

{% endblock %}